package com.warmlight.voicepacket;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.warmlight.voicepacket.base.BaseActivity;
import com.warmlight.voicepacket.data.PlaydeatalData;
import com.warmlight.voicepacket.data.eventbus.NotifyPlayDetal;

import org.greenrobot.eventbus.EventBus;

public class MypalyModalCancel  extends BaseActivity {

    //列表数据
    private PlaydeatalData.DataBean.ListBean mData;
    private String status;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_myplaylistmodal);

        PlaydeatalData.DataBean.ListBean listData = (PlaydeatalData.DataBean.ListBean) getIntent().getSerializableExtra("mypaly");
        if(listData!=null){
            mData = listData;
        }
        Bundle extras = getIntent().getExtras();
        if (extras != null){
            if (extras.containsKey("status")){
                status = extras.getString("status");
            }
        }



        findViewById(R.id.tv_del_share).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                EventBus.getDefault().post(new NotifyPlayDetal("share",mData));
                finish();
            }
        });
        findViewById(R.id.tv_del_playlist).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                EventBus.getDefault().post(new NotifyPlayDetal("remove",mData));
//                ShareCollectCallBackUtils.collectCallBack(mData.getId(),"-1");
                finish();
            }
        });
        findViewById(R.id.tv_del_playcolloc).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                EventBus.getDefault().post(new NotifyPlayDetal("notifsy",mData));
                finish();
            }
        });

        TextView tv_public = findViewById(R.id.tv_public);

        String is_open = mData.getIs_open();
        if (!TextUtils.isEmpty(is_open)){
            tv_public.setVisibility(View.VISIBLE);
            if (TextUtils.equals("-1",is_open)){
                Drawable drawable = getResources().getDrawable(R.drawable.icon_public);
//一定要加这行！！！！！！！！！！！
                drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                tv_public.setCompoundDrawables(null,drawable,null,null);
                tv_public.setText("公开");
            }else{
                Drawable drawable = getResources().getDrawable(R.drawable.icon_private);
//一定要加这行！！！！！！！！！！！
                drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
                tv_public.setCompoundDrawables(null,drawable,null,null);
                tv_public.setText("私密");
            }
        }else{
            tv_public.setVisibility(View.GONE);
        }

        if (TextUtils.equals("-1",status)){
            tv_public.setVisibility(View.GONE);
            findViewById(R.id.tv_del_share).setVisibility(View.GONE);
            findViewById(R.id.tv_del_playcolloc).setVisibility(View.GONE);
        }

        tv_public.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(new NotifyPlayDetal("public",mData));
                finish();
            }
        });

//
        findViewById(R.id.iv_grey).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

    @Override
    public void startActivity(Intent intent) {
        super.startActivity(intent);
        overridePendingTransition(R.anim.slide_bottom_in, R.anim.slide_bottom_out);
    }

    @Override
    public void startActivityForResult(Intent intent, int requestCode, Bundle options) {
        super.startActivityForResult(intent, requestCode, options);
        overridePendingTransition(R.anim.slide_bottom_in, R.anim.slide_bottom_out);
    }

    @Override
    public void finish() {
        super.finish();
        overridePendingTransition(R.anim.slide_bottom_in, R.anim.slide_bottom_out);
    }
}
